/*
 * Copyright (C) RT, 2017 by gf.wu
 */
package com.zgys.mes.util.deadlock;

import com.zgys.mes.util.Log;

import java.lang.management.ThreadInfo;


public class DeadLockConsoleHandler implements DeadLockHandler {
    public void handle(ThreadInfo[] threadInfos) {
        if (threadInfos == null) {
            return;
        }

        Log.error("*************** 发现线程死锁 ***********");

        for (ThreadInfo thread : threadInfos) {
            StringBuilder sb = new StringBuilder();
            for (StackTraceElement trace : thread.getStackTrace()) {
                sb.append(trace.toString());
            }

            Log.error("threadInfo={}。堆栈信息如下：\n{}", thread.toString(), sb.toString());
        }
    }
}
